package com.xiaohe.gulimall.member.web;

import com.alibaba.fastjson.JSON;
import com.xiaohe.common.utils.R;
import com.xiaohe.gulimall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

@Controller
public class MemberWebController {

    @Autowired
    private OrderFeignService orderFeignService;
    @GetMapping("/memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum",defaultValue = "1") String pageNum, Model model){
        //查询出当前登录用户的所有订单列表信息
         Map<String,Object> page = new HashMap<>();
         page.put("page",pageNum);

        R orderInfo = orderFeignService.listWithItem(page);
        System.out.println(JSON.toJSONString(orderInfo));
        model.addAttribute("orders",orderInfo);
        return "orderList";
    }
}
